package com.five.constants;

import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

public class StatusConstant {


    public static class ChapterStatus {

        // 待审
        public static final Byte CHAPTER_PENDING = 0;
        // 审核中
        public static final Byte CHAPTER_AUDITING = 1;
        // 通过
        public static final Byte CHAPTER_PASS = 1;  // 注意：此处与CHAPTER_AUDITING值相同，可能是业务设计或笔误
        // 驳回
        public static final Byte CHAPTER_REJECT = -1;

        public static final Byte CHAPTER_LIANZAI = 2;

        // 存储所有有效的章节状态
        private static final Set<Byte> VALID_CHAPTER_STATUSES;

        static {
            Set<Byte> statuses = new HashSet<>();
            statuses.add(CHAPTER_PENDING);
            statuses.add(CHAPTER_AUDITING);
            statuses.add(CHAPTER_PASS);
            statuses.add(CHAPTER_REJECT);
            statuses.add(CHAPTER_LIANZAI);
            // 转为不可变集合，防止外部修改
            VALID_CHAPTER_STATUSES = Collections.unmodifiableSet(statuses);
        }

    }

    public static class NovelStatus {

        // 待审
        public static final Byte NOVEL_PENDING = 0;
        // 连载
        public static final Byte NOVEL_SERIALIZING = 1;
        // 已完结
        public static final Byte NOVEL_ENDED = 2;
        // 驳回
        public static final Byte NOVEL_REJECT = -1;

        // 存储所有有效的小说状态
        private static final Set<Byte> VALID_NOVEL_STATUSES;

        static {
            Set<Byte> statuses = new HashSet<>();
            statuses.add(NOVEL_PENDING);
            statuses.add(NOVEL_SERIALIZING);
            statuses.add(NOVEL_ENDED);
            statuses.add(NOVEL_REJECT);
            // 转为不可变集合，防止外部修改
            VALID_NOVEL_STATUSES = Collections.unmodifiableSet(statuses);
        }
    }

    /**
     * 校验章节状态是否有效
     *
     * @param status 章节状态
     * @return 是否有效
     */
    public static boolean isValidChapterStatus(Byte status) {
        // 利用集合的contains方法判断，逻辑更简洁
        return ChapterStatus.VALID_CHAPTER_STATUSES.contains(status);
    }

    /**
     * 校验小说状态是否有效
     *
     * @param status 小说状态
     * @return 是否有效
     */
    public static boolean isValidNovelStatus(Byte status) {
        // 利用集合的contains方法判断，逻辑更简洁
        return NovelStatus.VALID_NOVEL_STATUSES.contains(status);
    }
}